package com.smyh.model.tableModel;

/**
 * Created by 姜龙 on 2016/7/8.
 */

import android.content.Context;
import android.view.Gravity;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

import com.smyh.UIM.R;

public class AddHeadRow  {


    public static TableRow addTableRow(Context context,String[] header ,Integer integer){

        TableRow tableRow = new TableRow(context);
        for(int i = 0;i<header.length;i++){
            TextView textView = new TextView(context);
            textView.setPadding(10,10,10,10);
            TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.MATCH_PARENT);
            textView.setLayoutParams(params);
            params.leftMargin = KtableView. lineWidth;
            params.topMargin = KtableView. lineWidth;
            params.weight =1;
            textView.setGravity(Gravity.CENTER);  //文本居中显示
            textView.setSingleLine(false);
            textView.setMaxEms(10);
            textView.setBackgroundResource(R.color.tableHead); //设施背景颜色
            textView.setText(header[i]);
            tableRow.addView(textView);
        }
        tableRow.setLayoutParams(new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
        return tableRow;
    }




}